<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let obj = {
        a: "zs",
        gf: {
          b: "lidi",
          f: {
            c: "ww",
            s: {
              d: "zl",
            },
          },
        },
      };
      function shallowRef(obj) {
        return shallowReactive({ value: obj });
      }
      function shallowReactive(obj) {
        return new Proxy(obj, {
          get(obj, key) {
            console.log("访问了key");
            return obj[key];
          },
          set(obj, key, val) {
            console.log("更新了ui", val);
            obj[key] = val;
          },
        });
      }
      let state = shallowRef(obj);
      state.value = {
        a: "1",
        gf: {
          b: "2",
          f: {
            c: "3",
            s: {
              d: "4",
            },
          },
        },
      };

      console.log(state);
    </script>
  </body>
</html>
